﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test2 : MonoBehaviour
{
    private GameObject gGameObject;
     
    // Use this for initialization
    void Start()
    {
        gGameObject = GameObject.Find("Cube");
    }

    // Update is called once per frame
    void Update()
    {

        //if (Input.GetKeyDown(KeyCode.Q))//通过Q键切换第一视觉及上帝
        //{
        //    GameObject pGameOject = GameObject.Instantiate(gGameObject);
        //  //GameObject pGameOject = gGameObject;
        //    GameObject.Destroy(gGameObject);
        //    gGameObject = null;
        //    if (pGameOject !=null)
        //    {
        //        pGameOject.transform.position = new Vector3(2, 0, 0);
        //    }

        //}
    }

    public GameObject ReturnObject()
    {
        if (gGameObject != null)
        { 
            GameObject pGameOject = GameObject.Instantiate(gGameObject);
          //  GameObject.Destroy(gGameObject);
            gGameObject = null;
            return pGameOject;
        }
        return null;
    }
}
